# -*- coding: utf-8 -*-

import wx
import wx.grid

class Entry(object):
    def __init__(self, pos, first, last):
        self.pos = pos
        self.first = first
        self.last = last


class SubTable(wx.grid.PyGridTableBase):
    colLabels = ("first", "last")
    colAttrs = colLabels
    def __init__(self, entry):
        wx.grid.PyGridTableBase.__init__(self)
        self.entry = entry
    def GetNumberRows(self):
        return 1
    def GetNumberCols(self):
        return 2
    def GetRowLabelValue(self, row):
        return self.entry[row].pos
    def GetColLabelValue(self, col):
        return self.colLabels[col]
    def GetValue(self, row, col):
#        entry = self.entry[row]
        return getattr(self.entry, self.colAttrs[col])
    def IsEmptyCell(self, row, col):
        return False
    def SetValue(self, row, col, value):
        pass


class SimpleGrid(wx.grid.Grid):
    data = (("Tom","zhang"), ("Mark","Wang"), ("Mark","Wang"))
    def __init__(self, parent, id=-1):
        wx.grid.Grid.__init__(self, parent)
        entry = Entry(1, "Tom", "zhang")
        subTable = SubTable(entry)
        self.SetTable(subTable)


class Frame(wx.Frame):
    def __init__(self, parent, id=-1, title="Simple Grid"):
        wx.Frame.__init__(self, parent, id, title)
        grid = SimpleGrid(self)


if __name__ == '__main__':
    app = wx.PySimpleApp()
    frame = Frame(None)
    frame.Show()
    app.MainLoop()